home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / frmscrol / scroll.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-12-01  |  4.0 KB  |  145 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3795
  5.    ClientLeft      =   945
  6.    ClientTop       =   2220
  7.    ClientWidth     =   5070
  8.    Height          =   4485
  9.    Left            =   885
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3795
  12.    ScaleWidth      =   5070
  13.    Top             =   1590
  14.    Width           =   5190
  15.    Begin CommonDialog CMDialog1 
  16.       Left            =   0
  17.       Top             =   15
  18.    End
  19.    Begin PictureBox Picture1 
  20.       Height          =   3780
  21.       Left            =   -75
  22.       ScaleHeight     =   3750
  23.       ScaleWidth      =   5145
  24.       TabIndex        =   0
  25.       Top             =   0
  26.       Width           =   5175
  27.       Begin PictureBox Picture2 
  28.          AutoSize        =   -1  'True
  29.          BorderStyle     =   0  'None
  30.          Height          =   2535
  31.          Left            =   810
  32.          Picture         =   SCROLL.FRX:0000
  33.          ScaleHeight     =   2535
  34.          ScaleWidth      =   3300
  35.          TabIndex        =   3
  36.          Top             =   390
  37.          Width           =   3300
  38.       End
  39.       Begin HScrollBar HScroll1 
  40.          Height          =   270
  41.          LargeChange     =   200
  42.          Left            =   30
  43.          TabIndex        =   2
  44.          Top             =   3450
  45.          Width           =   3495
  46.       End
  47.       Begin VScrollBar VScroll1 
  48.          Height          =   3510
  49.          LargeChange     =   200
  50.          Left            =   4845
  51.          TabIndex        =   1
  52.          Top             =   -15
  53.          Width           =   270
  54.       End
  55.    End
  56.    Begin Menu mnuFile 
  57.       Caption         =   "&File"
  58.       Begin Menu mnuOpen 
  59.          Caption         =   "&Open Bitmap"
  60.       End
  61.       Begin Menu mnuExit 
  62.          Caption         =   "E&xit"
  63.       End
  64.    End
  65. Option Explicit
  66. Sub DisplayScrollBars ()
  67.   Dim x, y, state As Integer
  68.   x = 0
  69.   y = 0
  70.   picture1.Height = form1.ScaleHeight
  71.   picture1.Width = form1.ScaleWidth
  72.   picture2.AutoSize = True
  73.   If picture2.Height < picture1.Height Then
  74.     vscroll1.Visible = False
  75.   Else
  76.     x = 1
  77.   End If
  78.   If picture2.Width < picture1.Width Then
  79.     hscroll1.Visible = False
  80.   Else
  81.     y = 2
  82.   End If
  83.   state = x + y
  84.   Select Case state
  85.   ' both invisible
  86.   Case 0
  87.     picture2.Move 0, 0
  88.     hscroll1.Value = 0
  89.     vscroll1.Value = 0
  90.   ' vscroll only
  91.   Case 1
  92.     vscroll1.Move form1.ScaleWidth - vscroll1.Width, 0
  93.     vscroll1.Height = form1.ScaleHeight
  94.     vscroll1.Visible = True
  95.     hscroll1.Value = 0
  96.   ' hscroll only
  97.   Case 2
  98.     hscroll1.Move 0, form1.ScaleHeight - hscroll1.Height
  99.     hscroll1.Width = form1.ScaleWidth
  100.     hscroll1.Visible = True
  101.     vscroll1.Value = 0
  102.   ' hscroll and vscroll
  103.   Case 3
  104.     vscroll1.Move form1.ScaleWidth - vscroll1.Width, 0
  105.     vscroll1.Height = form1.ScaleHeight - hscroll1.Height
  106.     hscroll1.Move 0, form1.ScaleHeight - hscroll1.Height
  107.     hscroll1.Width = form1.ScaleWidth
  108.     hscroll1.Visible = True
  109.     vscroll1.Visible = True
  110.     picture2.AutoSize = False
  111.     picture2.Height = picture1.Height - picture2.Top - hscroll1.Height
  112.     picture2.Width = picture1.Width - picture2.Left - vscroll1.Width
  113.   End Select
  114. End Sub
  115. Sub Form_Load ()
  116. picture1.Move 0, 0
  117. picture2.Move 0, 0
  118. picture1.Height = form1.ScaleHeight
  119. hscroll1.Max = picture2.Width
  120. vscroll1.Max = picture2.Height
  121. End Sub
  122. Sub Form_Resize ()
  123.   DisplayScrollBars
  124. End Sub
  125. Sub HScroll1_Change ()
  126.   picture2.Left = -(hscroll1.Value)
  127.   picture2.Width = picture1.Width - picture2.Left - vscroll1.Width
  128. End Sub
  129. Sub mnuExit_Click ()
  130.   End
  131. End Sub
  132. Sub mnuOpen_Click ()
  133.   CMDialog1.Filter = "*.BMP (Bitmaps)|*.BMP"
  134.   CMDialog1.FilterIndex = 1
  135.   CMDialog1.Action = 1
  136.   picture2.Picture = LoadPicture(CMDialog1.Filename)
  137.   hscroll1.Max = picture2.Width
  138.   vscroll1.Max = picture2.Height
  139.   DisplayScrollBars
  140. End Sub
  141. Sub VScroll1_Change ()
  142.   picture2.Top = -(vscroll1.Value)
  143.   picture2.Height = picture1.Height - picture2.Top - hscroll1.Height
  144. End Sub
  145.